package cn.iocoder.yudao.module.picturebook.dal.mysql.classmember;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.picturebook.dal.dataobject.classmember.ClassMemberDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.picturebook.controller.admin.classmember.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 班级成员关联 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ClassMemberMapper extends BaseMapperX<ClassMemberDO> {

    default PageResult<ClassMemberDO> selectPage(ClassMemberPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ClassMemberDO>()
                .eqIfPresent(ClassMemberDO::getClassId, reqVO.getClassId())
                .eqIfPresent(ClassMemberDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ClassMemberDO::getRole, reqVO.getRole())
                .betweenIfPresent(ClassMemberDO::getJoinTime, reqVO.getJoinTime())
                .betweenIfPresent(ClassMemberDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ClassMemberDO::getId));
    }

    List<ClassMemberDO> getClassByUser(Integer userId);

    ClassMemberDO queryClassMemberByClassIdAndUserId(@Param("classId") Long classId, @Param("userId") Long userId);

    List<ClassMemberDO> getClassAllMemberByClassId(Long classId);

    void updateClassMemberRole(@Param("userId") Long teacherId, @Param("id") Long id, @Param("role") int i);

    String getMemberName(@Param("userId") Long userId,@Param("classId") Long classId);

    Boolean deleteByClassIdAndUserId(@Param("classId") Long classId,@Param("userId") Long userId);

    int getClassMemberCount(Long classId);

    List<ClassMemberDO> getClassMemberByClassIdAndUserId(@Param("classId") Long classId, @Param("userId") Long userId);

    ClassMemberDO getClassMember(@Param("userId") Long memberId, @Param("classId") Long classId);

    void DeleteById(Long id);
}